export default {
  data() {
    return {
      commonMap: {
        formSubmitLoading: false
      },
      dialogVisible: false,
      form: {
        ${(businessCode?uncap_first)!''}Code: '',
        name: ''
      },
      formRules: {
        ${(businessCode?uncap_first)!''}Code: [
          { required: true, message: `请输入${businessName!}编号`, trigger: 'blur' },
          { min: 1, max: 36, message: '${businessName!}编号长度在 1 到 36 个字符', trigger: 'blur' }
        ],
        name: [
          { required: true, message: `请输入${businessName!}名称`, trigger: 'blur' },
          { min: 1, max: 36, message: '${businessName!}名称长度在 1 到 36 个字符', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    dialogOpen() {
      this.$http({
        url: '${api_root_url!}/v1/${moduleMapperCode}/${(businessCode?uncap_first)!''}/getById/modify',
        method: 'post',
        data: { ${(businessCode?uncap_first)!''}Id: this.form.${(businessCode?uncap_first)!''}Id }
      }).then(response => {
        this.form = response.data
      })
    },
    dialogClose() {
      this.$refs.form.resetFields()
    },
    formSubmitClick() {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }

        this.$http({
          url: '${api_root_url!}/v1/${moduleMapperCode}/${(businessCode?uncap_first)!''}/updateById',
          method: 'post',
          data: this.form,
          thenRequest: () => {
            this.commonMap.formSubmitLoading = true
          },
          thenResponse: () => {
            this.commonMap.formSubmitLoading = false
          },
          successMessage: '${businessName!}修改成功',
          errorMessage: '${businessName!}修改失败：'
        }).then(response => {
          this.$emit('formSubmitClick')

          this.dialogVisible = false
        })
      })
    }
  }
}
